import * as echarts from 'echarts'

/**
 * @description 初始化echarts实例
 * @param opt
 * @param id
 * @constructor
 * @author younghero
 */
export const EchartsOptions = (opt, id = '') => {
    const dom = document.getElementById(id)
    if (!dom) return
    dom.setAttribute('_echarts_instance_', '')
    const myChart = echarts.init(dom)
    myChart.setOption(opt, true)
    // 重新把配置好的新数据给实例对象
    window.addEventListener('resize', () => {
        myChart.resize()
    })

    return myChart
}
